package com.ruoyi.web.controller.vantController.customerController;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.construction.strategy.ConstructionStrategy;
import com.ruoyi.system.domain.customer.CustomerLogin;
import com.ruoyi.system.service.construction.StrategyVrService;
import com.ruoyi.system.service.construction.strategy.ConstructionStrategyService;
import com.ruoyi.system.utils.TokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/api/customer/strategy")
@CrossOrigin
public class ApiConstructionStrategyController extends BaseController {

    @Autowired
    private ConstructionStrategyService constructionStrategyService;
    @Autowired
    private StrategyVrService strategyVrService;
    @Autowired
    private HttpServletRequest request;

    @Autowired
    private TokenUtils tokenUtils;


    @GetMapping(value = "/gonglvList")
    public TableDataInfo gonglvList(ConstructionStrategy constructionStrategy){
        CustomerLogin customerLogin = tokenUtils.getLoginCustomer(request);
        constructionStrategy.setUserId(customerLogin.getCustomerId());
        List<ConstructionStrategy> list = constructionStrategyService.gonglvList(constructionStrategy);
        return getDataTable(list);
    }

    @PostMapping("/gonglvListCount")
    public Long gonglvListCount(ConstructionStrategy constructionStrategy){
        CustomerLogin customerLogin = tokenUtils.getLoginCustomer(request);
        constructionStrategy.setUserId(customerLogin.getCustomerId());
        return constructionStrategyService.gonglvListCount(constructionStrategy);
    }


    @GetMapping(value = "/findAllSand")
    public List<ConstructionStrategy> findAllSand(ConstructionStrategy constructionStrategy){
        List<ConstructionStrategy> allSand = constructionStrategyService.findAllSand(constructionStrategy);
        return allSand;
    }


    @GetMapping(value ="/findAllSandById/{vrId}")
    public AjaxResult findAllSandById(@PathVariable("vrId") Long vrId){
        System.err.println("**********vrId******vrId************"+vrId);
        return AjaxResult.success(strategyVrService.selectStrategyVrById(vrId));
    }

    @GetMapping(value = "/findAllZhengWu")
    public List<ConstructionStrategy> findAllZhengWu(ConstructionStrategy constructionStrategy){
        List<ConstructionStrategy> allSand = constructionStrategyService.findAllZhengWu(constructionStrategy);
        return allSand;
    }

    @GetMapping(value = "/findAllShiPin")
    public List<ConstructionStrategy> findAllShiPin(ConstructionStrategy constructionStrategy){
        List<ConstructionStrategy> allSand = constructionStrategyService.findAllShiPin(constructionStrategy);
        return allSand;
    }

    @GetMapping(value = "/findAllZhengWuById/{constructionStrategyId}")
    public AjaxResult findAllZhengWuById(@PathVariable("constructionStrategyId") Long constructionStrategyId){
        System.err.println("********constructionStrategyId********"+constructionStrategyId);
        return AjaxResult.success(constructionStrategyService.selectConstructionStrategyById(constructionStrategyId));
    }






}
